//处理时间的函数
export function formatDate(type,date,format='content'){
    let time = ''
    const dateObj = {
        year:date.getFullYear(),
        month:date.getMonth() + 1,
        day:date.getDate(),
        hours:date.getHours(),
        minute:date.getMinutes(),
        second:date.getSeconds()
    }
    if(type == 'year'){
        time = dateObj.year + ''
    }
    else if(type == 'month'){
        time = dateObj.month + ''
    }
    else if(type == 'day'){
        time = dateObj.day + ''
    }
    else if(type == 'hours'){
        time = dateObj.hours + ''
    }
    else if(type == 'minute'){
        time = dateObj.minute + ''
    }
    else if(type == 'seconds'){
        time = dateObj.second + ''
    }
    //年月日
    else if(type == 'yearMonthSet'){
        if(format == 'content'){
            time = `${dateObj.year}年${dateObj.month}月${dateObj.day}日`
        }else{
            time = `${dateObj.year}${format}${dateObj.month}${format}${dateObj.day}`
        }

    }
    //月日
    else if(type == 'MonthSet'){
        if(format == 'content'){
            time = `${dateObj.month}月${dateObj.day}日`
        }else{
            time = `${dateObj.month}${format}${dateObj.day}`
        }

    }
    // 全部
    else if(type == 'dateSet'){
        if(format == 'content'){
            time = `${dateObj.year}年${dateObj.month}月${dateObj.day}日 ${dateObj.hours}:${dateObj.minute}:${dateObj.second}`
        }else {
            time = `${dateObj.year}${format}${dateObj.month}${format}${dateObj.day} ${dateObj.hours}:${dateObj.minute}:${dateObj.second}`
        }

    }
    return time
}
